home *** CD-ROM | disk | FTP | other *** search
- //========================================================================================
- //
- // Ex-vxx.c - Video export plugin for Premiere.
- //
- // Part of the Adobe Premiere 4.2 Plug-in Developer's Toolkit.
- //
- // Copyright 1996, Adobe Systems Incorporated, all rights reserved worldwide.
- //
- // Written by Nick Schlott.
- //
- // This plugin exports from a source clip to a mythical format
- // called .VXX. This file format consists of a short header,
- // followed by n frames of 32bpp RGB frames.
- //
- // 1.00 1/25/94 njs
- // 1.02 1/10/96 ba Updated for Premiere 4.2 and MSVC++ 2.2 & 4.0.
- //
- //----------------------------------------------------------------------------------------
-
- #include <windows.h>
-
- #include "Compat.h"
- #include "Premiere.h"
-
-
- char *vxxHeader = "VXX File Header ->\0";
- char *vxxBody = "VXX Body ->\0";
-
- HINSTANCE ghInst;
-
- BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- ghInst = hDLL;
- break;
-
- case DLL_THREAD_ATTACH:
- break;
-
- case DLL_THREAD_DETACH:
- break;
-
- case DLL_PROCESS_DETACH:
- break;
- }
- return(TRUE);
- }
-
-
- //--------------------------------------------------------------------------
- // prompt for an output file
-
- int PutFile (char *name)
- {
- OPENFILENAME ofn;
-
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.lpstrFilter = "*.vxx";
- ofn.hwndOwner = GetLastActivePopup(GetMainWnd());
- ofn.hInstance = ghInst;
- ofn.nFilterIndex = 0;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 31;
- name[0] = 0;
- ofn.lpstrFile = (LPSTR)name;
- ofn.nMaxFile = _MAX_PATH;
- ofn.lpstrInitialDir = NULL;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFileOffset = ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "vxx";
- ofn.lCustData = 0;
- ofn.lpfnHook = NULL;
- ofn.lpTemplateName = NULL;
- ofn.lpstrTitle=NULL;
- ofn.lpstrTitle=NULL;
- return GetSaveFileName(&ofn);
- }
-
-
- //--------------------------------------------------------------------------
- // entry point
-
- int PRMEXPORT xExport (short selector, DataExportHandle theData)
- {
- short result = 0, err;
- long first, last, current, outsize, numframes;
- GetVidCallBack getvid;
- PWorldID thePort;
- PPixHand pix;
- Ptr srcbase;
- HFILE ref;
- char fname[_MAX_PATH];
- OFSTRUCT of;
- RECT box;
-
- if (selector == edExecute)
- {
- result = 1;
- getvid = (*theData)->getVideo; // get the frame callback function
-
- // prompt for file name
-
- if(PutFile(fname))
- {
- // create the output file
-
- ref = OpenFile(fname, &of, OF_CREATE | OF_READWRITE);
- if (ref != HFILE_ERROR)
- {
-
- // calc the number of frames
-
- first = (*theData)->markers[0]; // get the IN point
- last = (*theData)->markers[1]; // get the OUT point
- numframes = last-first;
-
- // make a new pixmap to image RGB data to.
- // get the thePort's pixmap
-
- box = (*theData)->bounds;
- err = NewPWorld(&thePort, &box);
- if(!err)
- {
- pix = GetPWorldBits(thePort);
-
- // write the header
-
- _hwrite(ref, vxxHeader, strlen(vxxHeader));
- _hwrite(ref, &(char)numframes, sizeof(long));
- _hwrite(ref, &(char)box.left, sizeof(long));
- _hwrite(ref, &(char)box.top, sizeof(long));
- _hwrite(ref, &(char)box.right, sizeof(long));
- _hwrite(ref, &(char)box.bottom, sizeof(long));
- _hwrite(ref, &(char)(*pix)->rowbytes, sizeof((*pix)->rowbytes));
- _hwrite(ref, vxxBody, strlen(vxxBody));
-
- // Loop until we're done exporting
-
- for (current = first; current < last ; current++)
- {
- (getvid)(current, thePort, &box, (*theData)->privateData);
- srcbase = (*pix)->pix;
- outsize = (*pix)->rowbytes * (box.bottom - box.top);
- _hwrite(ref, srcbase, outsize);
- }
- _lclose(ref);
-
- // nuke the port
-
- if (thePort)
- DisposePWorld(thePort);
-
- result = 0;
- }
- }
- }
- }
- return (result);
- }
-